// import { globalIgnores } from 'eslint/config'
import { defineConfigWithVueTs, vueTsConfigs, configureVueProject } from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import autoImport from './.eslintrc-auto-import.json'
configureVueProject({ scriptLangs: ['ts', 'tsx'] })

export default defineConfigWithVueTs(
	{
		ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**', 'node_modules/**', './vite.config.ts']
	},
	{
		name: 'app/files-to-lint',
		files: ['**/*.{ts,mts,tsx,vue}'],
		languageOptions: {
			globals: {
				...autoImport.globals
			}
		}
	},

	pluginVue.configs['flat/essential'],
	vueTsConfigs.recommended,
	skipFormatting,
	{
		name: 'custom-rules',
		rules: {
			camelcase: 0,
			'comma-dangle': [2, 'only-multiline'],
			'no-useless-escape': 0,
			quotes: [1, 'single'],
			'no-irregular-whitespace': 2,
			'use-isnan': 2,
			'vars-on-top': 2,
			'semi-spacing': [2, { before: false, after: true }],
			'no-multi-spaces': 1,
			'no-trailing-spaces': 2,
			'comma-spacing': 2,
			'no-unused-vars': 'warn',
			'no-tabs': 'off',
			'no-unreachable': 'off',
			indent: 'off',
			'no-extend-native': 2,
			'no-return-assign': 0,
			'object-curly-spacing': 0,
			'space-before-function-paren': [0, 'always'],
			// max-lines: 限制文件的最大行数
			'max-lines': ['error', { max: 800 }],
			'vue/no-use-v-if-with-v-for': 2,
			'vue/no-empty-component-block': 2,
			'vue/order-in-components': 2,
			'vue/prop-name-casing': 2,
			'vue/require-default-prop': 2,
			'vue/require-prop-types': 2,
			'vue/require-v-for-key': 2,
			'vue/valid-v-bind': 2,
			'vue/multi-word-component-names': 0,
			'vue/comment-directive': 0,
			// 函数
			'max-lines-per-function': ['error', { max: 80 }],
			'max-params': ['error', 3],
			'prefer-const': 'error',
			'no-const-assign': 'error',
			'no-var': 'error',
			'no-prototype-builtins': 'error',
			'array-callback-return': 'warn',
			'no-new-func': 'error',
			eqeqeq: 'warn',
			'no-case-declarations': 'warn',
			'no-unneeded-ternary': 'error',
			'no-empty-function': ['error'],
			'no-param-reassign': ['error'],
			'no-multiple-empty-lines': ['error', { max: 1 }],
			'max-classes-per-file': ['error', 1],
			'max-nested-callbacks': ['error', { max: 2 }],
			'no-duplicate-imports': ['error'],
			// max-len: 限制每行代码的最大字符数。
			// 'max-len': ['error', { code: 130 }],
			// 函数调用间距
			'func-call-spacing': 'error',
			// 键间距
			'key-spacing': ['error', { beforeColon: false }],
			// 禁止没有必要的括号
			'no-extra-parens': 'error',
			// 块的最大深度
			'max-depth': ['error', 4],
			// 箭头函数风格
			// 'arrow-body-style': ['error', 'always'],
			// 类强制使用 this
			'class-methods-use-this': 'error',
			// 禁止不必要的嵌套块
			'no-lone-blocks': 'warn',
			'@typescript-eslint/ban-ts-comment': 'off'
		}
	}
)
